Manage sensitivity parameters with node built#3764
Conversation
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
📝 WalkthroughWalkthroughThis pull request migrates build status constants and components from local definitions to external imports from Changes
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/parameters-tabs.tsx (1)
70-70:⚠️ Potential issue | 🟡 MinorInconsistent migration: Still using local
BUILD_STATUSinstead ofBuildStatusfrom commons-ui.This file imports
BUILD_STATUSfrom'./network/constants'(line 70) and uses it in theSecurityAnalysisParametersInlinecomponent (lines 319-321). According to the PR objectives,BUILD_STATUSis being moved to@gridsuite/commons-ui, and other files in this PR have already migrated to useBuildStatusfrom that package.🔧 Proposed fix to complete the migration
-import { BUILD_STATUS } from './network/constants';Update the import at line 52 to include
BuildStatus:import { ComputingType, DynamicMarginCalculationInline, ... + BuildStatus, } from '@gridsuite/commons-ui';Then update lines 319-321:
isBuiltCurrentNode={ - currentNodeBuildStatus !== BUILD_STATUS.NOT_BUILT && - currentNodeBuildStatus !== BUILD_STATUS.BUILDING + currentNodeBuildStatus !== BuildStatus.NOT_BUILT && + currentNodeBuildStatus !== BuildStatus.BUILDING }Also applies to: 319-321
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters-tabs.tsx` at line 70, The file still imports the local BUILD_STATUS constant and uses it in SecurityAnalysisParametersInline; replace the local import and usage with the canonical BuildStatus from `@gridsuite/commons-ui`: update the import to import { BuildStatus } from '@gridsuite/commons-ui' instead of BUILD_STATUS from './network/constants', then update the SecurityAnalysisParametersInline code that references BUILD_STATUS (lines around the SecurityAnalysisParametersInline component) to use BuildStatus (matching the enum/shape exported by commons-ui) so the component aligns with the other migrated files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/components/parameters-tabs.tsx`:
- Line 70: The file still imports the local BUILD_STATUS constant and uses it in
SecurityAnalysisParametersInline; replace the local import and usage with the
canonical BuildStatus from `@gridsuite/commons-ui`: update the import to import {
BuildStatus } from '@gridsuite/commons-ui' instead of BUILD_STATUS from
'./network/constants', then update the SecurityAnalysisParametersInline code
that references BUILD_STATUS (lines around the SecurityAnalysisParametersInline
component) to use BuildStatus (matching the enum/shape exported by commons-ui)
so the component aligns with the other migrated files.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6d80b43d-adee-4a6d-a9cf-fa013c343f01
📒 Files selected for processing (16)
src/components/graph/menus/create-node-menu.tsxsrc/components/graph/menus/root-network/unbuild-all-nodes-button.tsxsrc/components/graph/network-modification-tree-model.tssrc/components/graph/nodes/build-button.tsxsrc/components/graph/nodes/build-status-chip.tsxsrc/components/graph/nodes/network-modification-node.tsxsrc/components/graph/tree-node.type.tssrc/components/graph/util/model-functions.tssrc/components/network-modification-tree-pane.jsxsrc/components/network/constants.tssrc/components/parameters-tabs.tsxsrc/components/results/common/computation-report-viewer.tsxsrc/components/study-container.jsxsrc/services/study/tree-subtree.tssrc/translations/en.jsonsrc/translations/fr.json
💤 Files with no reviewable changes (4)
- src/components/network/constants.ts
- src/translations/en.json
- src/translations/fr.json
- src/components/graph/nodes/build-status-chip.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/parameters-tabs.tsx (1)
91-91: UsecurrentNodeBuildStatusdirectly to avoid unnecessary callback invalidation
displayTabnow depends on the fullcurrentNodeobject only to readglobalBuildStatus. SincecurrentTreeNodeis frequently recreated as a new object reference, this causes avoidableuseCallbackchurn. PassingcurrentNodeBuildStatusdirectly keeps this stable and simpler.Refactor sketch
- const currentNode = useSelector((state: AppState) => state.currentTreeNode ?? null); const currentNodeUuid = useSelector((state: AppState) => state.currentTreeNode?.id ?? null); const currentNodeBuildStatus = useSelector((state: AppState) => state.currentTreeNode?.data.globalBuildStatus); @@ - globalBuildStatus={currentNode?.data?.globalBuildStatus} + globalBuildStatus={currentNodeBuildStatus} @@ - currentNode, tabValue, @@ currentNodeBuildStatus,Also applies to: 334-334, 399-399
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters-tabs.tsx` at line 91, The displayTab callback currently depends on the full currentTreeNode object (selected via const currentNode = useSelector((state: AppState) => state.currentTreeNode ?? null)), causing unnecessary invalidation when the node object reference changes; change the selector to pull only the primitive/currentNodeBuildStatus (e.g., const currentNodeBuildStatus = useSelector((s: AppState) => s.currentTreeNode?.globalBuildStatus ?? null)) and update displayTab and any other callbacks that only need globalBuildStatus to depend on currentNodeBuildStatus instead of currentNode; apply the same change to the other occurrences noted (the selectors/usages around the displayTab-like callbacks at the locations referenced) so callbacks remain stable and avoid churn.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/parameters-tabs.tsx`:
- Around line 319-320: The current check using negations allows undefined to be
treated as "built"; update the isBuiltCurrentNode logic to explicitly check for
the built state(s) rather than relying on !== comparisons. Replace the
expression using currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
currentNodeBuildStatus !== BuildStatus.BUILDING with an explicit equality check
(e.g., currentNodeBuildStatus === BuildStatus.BUILT or currentNodeBuildStatus
=== <other explicit built enum>) so that undefined or unknown statuses evaluate
to false; adjust any usage inside ParametersTabs (or the isBuiltCurrentNode
variable) accordingly.
---
Nitpick comments:
In `@src/components/parameters-tabs.tsx`:
- Line 91: The displayTab callback currently depends on the full currentTreeNode
object (selected via const currentNode = useSelector((state: AppState) =>
state.currentTreeNode ?? null)), causing unnecessary invalidation when the node
object reference changes; change the selector to pull only the
primitive/currentNodeBuildStatus (e.g., const currentNodeBuildStatus =
useSelector((s: AppState) => s.currentTreeNode?.globalBuildStatus ?? null)) and
update displayTab and any other callbacks that only need globalBuildStatus to
depend on currentNodeBuildStatus instead of currentNode; apply the same change
to the other occurrences noted (the selectors/usages around the displayTab-like
callbacks at the locations referenced) so callbacks remain stable and avoid
churn.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f1fd5b63-60bf-47c7-ab11-5b8b98781a78
📒 Files selected for processing (1)
src/components/parameters-tabs.tsx
| currentNodeBuildStatus !== BuildStatus.NOT_BUILT && | ||
| currentNodeBuildStatus !== BuildStatus.BUILDING |
There was a problem hiding this comment.
isBuiltCurrentNode currently treats unknown status as built
Because globalBuildStatus is optional, undefined can reach this check and evaluates to true with the current negated comparisons. That can enable Security Analysis on nodes with unknown build state.
Proposed fix
isBuiltCurrentNode={
- currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
- currentNodeBuildStatus !== BuildStatus.BUILDING
+ currentNodeBuildStatus != null &&
+ currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
+ currentNodeBuildStatus !== BuildStatus.BUILDING
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| currentNodeBuildStatus !== BuildStatus.NOT_BUILT && | |
| currentNodeBuildStatus !== BuildStatus.BUILDING | |
| currentNodeBuildStatus != null && | |
| currentNodeBuildStatus !== BuildStatus.NOT_BUILT && | |
| currentNodeBuildStatus !== BuildStatus.BUILDING |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/components/parameters-tabs.tsx` around lines 319 - 320, The current check
using negations allows undefined to be treated as "built"; update the
isBuiltCurrentNode logic to explicitly check for the built state(s) rather than
relying on !== comparisons. Replace the expression using currentNodeBuildStatus
!== BuildStatus.NOT_BUILT && currentNodeBuildStatus !== BuildStatus.BUILDING
with an explicit equality check (e.g., currentNodeBuildStatus ===
BuildStatus.BUILT or currentNodeBuildStatus === <other explicit built enum>) so
that undefined or unknown statuses evaluate to false; adjust any usage inside
ParametersTabs (or the isBuiltCurrentNode variable) accordingly.
PR Summary